<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //过滤filter
        let arr = ["星期一", "星期二", "星期三", "星期四", "星期五", "周末"]
        let res = arr.filter((value, index, obj) => {
            return value.length === 2
        })
        console.log("过滤的结果是：" + res)
            //查找find
        let res1 = arr.find((value, index, obj) => {
            return value.length === 3
        })
        console.log("查找的结果是：" + res1)
            //修改map
        let res2 = arr.map((value, index, obj) => {
            if (value === "星期四") {
                return "疯狂" + value + "v我50"
            } else if (value === "周末") {
                return value + "放假"
            } else {
                return value + "好痛苦"
            }
        })
        console.log(res2)
            //增加push
        let res3 = arr.push("不存在的星期八")
        console.log(arr)
            //增删splice
        let res4 = arr.splice(5, 2, "调休了哈哈")
        console.log(res4)
        arr.splice(1)
        console.log(arr)

        let arrA = [100, "呵", 233, "哇", 5]
        let v1 = arrA.reduce((previousValue, currentValue, index, array) => {
            if (typeof currentValue === 'number') {
                return previousValue + currentValue
            } else {
                return previousValue
            }
        }, 1)
        console.log(v1)

        //for循环
        let arrB = [0, 1, 2, 3, 4, 5]
        for (let i = 0; i < arrB.length; i++) {
            console.log(arrB[i])
        }

        for (aName of arrB) {
            console.log(aName)
        }

        for (aName in arrB) {
            console.log(aName) //打印下标
        }
        //定义对象
        let obj = {
            name: "黄紫红",
            age: "?"
        }
        console.log(obj.name, obj.age)
    </script>
</body>

</html>